<layout name="Iflayout"/>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function(){
        var ue = UE.getEditor('inputContent3');
    })
</script>

    <script type="text/javascript">
        $(function () {
            //缩略图上传
            var litpic_tip = $(".litpic_tip");
            var btn = $(".up-picture-btn span");
            $("#fileupload").wrap("<form id='myupload' action='/xyhai.php?s=/Public/upload/img_flag/1' method='post' enctype='multipart/form-data'></form>");
            $("#fileupload").change(function(){
                if($("#fileupload").val() == "") return;
                $("#myupload").ajaxSubmit({
                    dataType:  'json',
                    beforeSend: function() {
                        $('#litpic_show').empty();
                        btn.html("上传中...");
                    },
                    success: function(data) {
                        if(data.state == 'SUCCESS'){
                            var fileSize = parseFloat(data.info[0].size/1024).toFixed(2);
                            litpic_tip.html(""+ data.info[0].name +" 上传成功("+ fileSize +"k)");
                            var img = data.info[0].url;//原图
                            var timg = data.info[0].turl;//缩略图
                            $('#litpic_show').html("<img src='"+timg+"' width='120'>");
                            $("#litpic").val(img);
                        }else {
                            litpic_tip.html(data.state);
                        }
                        btn.html("添加图片");

                    },
                    error:function(xhr){
                        btn.html("上传失败");
                        litpic_tip.html(xhr);
                    }
                });
            });

            $('#CK_JumpUrl').click(function(){
                if($(this).prop('checked')) {
                    $('#JumpUrlDiv').show();

                }else {
                    $('#JumpUrlDiv').hide();
                }

            });

        });




        $(function () {

            $('#BrowerPicture').click(function(){
                layer.open({
                    type: 2,
                    title: 'XYHCMS',
                    shadeClose: true,
                    shade: 0.5,
                    area: ['670px', '350px'],
                    content: "/xyhai.php?s=/Public/browseFile/stype/picture"
                });
            });

        });


        function selectPicture(sfile) {
            layer.msg('选择文件成功')
            $("#litpic").val(sfile);
            $('#litpic_show').html("<img src='"+sfile+"' width='120'>");
        }


        function select_type(id) {
            $("#content_1").hide();
            $("#content_2").hide();
            $("#content_3").hide();
            $("#content_"+id).show();
        }
        $(function(){
            $("#content_1").show();
            $('#inputBlocktype').change(function(event) {
                var type = $(this).val();
                select_type(type);
            });
        });


    </script>


</head>
<body>
<div class="xyh-content">

    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em>
                修改自由块
            </h3>
        </div>

    </div>


    <div class="row">
        <div class="col-lg-12">

            <form method='post' class="form-horizontal" id="form_do" name="form_do" action="/xyhai.php?s=/Block/edit">

                <div class="form-group">
                    <label for="inputName" class="col-sm-2 control-label">名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="name" id="inputName" value="{$arr['name']}" class="form-control" placeholder="名称" required="required" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputBlocktype" class="col-sm-2 control-label">类型</label>
                    <div class="col-sm-9">
                        <select name="blocktype" id="inputBlocktype" class="form-control">


                            <foreach name="list" item="brr">
                                <option value="{$brr['value']}" {$brr['value']==$arr['blocktype'] ? "selected" : ""}>{$brr['name']}</option>
                            </foreach>


                        </select>
                    </div>
                </div>


                <div class="form-group" id="content_1" style="display:none;">
                    <label for="inputContent" class="col-sm-2 control-label">内容</label>
                    <div class="col-sm-9">
                        <textarea name="content[1]" id="inputContent"  class="form-control" rows="6">{$arr['content']}</textarea>
                    </div>
                </div>


                <div class="form-group" id="content_2" style="display:none;">
                    <label for="litpic" class="col-sm-2 control-label">内容</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="content[2]" id="litpic"  value="{$arr['content']}" placeholder="缩略图地址" />
                    </div>
                    <div class="col-sm-5">
                        <button class="btn btn-primary" type="button" id="BrowerPicture"><em class="glyphicon glyphicon-plus-sign"></em> 选择站内图片</button>
                        <div class="btn btn-success up-picture-btn">
                            <span><em class="glyphicon glyphicon-plus-sign"></em>添加图片</span>
                            <input id="fileupload" type="file" name="mypic">
                        </div>
                    </div>
                    <div class="row">
                        <label for="" class="col-sm-2 control-label"></label>
                        <div class="col-sm-9">
                            <div class="litpic_tip"></div>
                            <div id="litpic_show">
                                <img src="内容" width='120' />
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-group" id="content_3" style="display:none;">
                    <label for="inputContent" class="col-sm-2 control-label">内容</label>
                    <div class="col-sm-9">
                        <textarea name="content[3]" id="inputContent3" style="height: 370px;">{$arr['content']}</textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputRemark" class="col-sm-2 control-label">自由块说明</label>
                    <div class="col-sm-9">
                        <textarea name="remark" id="inputRemark" class="form-control">{$arr['remark']}</textarea>
                    </div>
                </div>

                <div class="row margin-botton-large">
                    <div class="col-sm-offset-2 col-sm-9">
                        <input type="hidden" name="id" value="2" />
                        <div class="btn-group">
                            <button type="submit" class="btn btn-primary"> <i class="glyphicon glyphicon-saved"></i>
                                保存
                            </button>
                            <button type="button" onclick="goUrl('index')" class="btn btn-default"> <i class="glyphicon glyphicon-chevron-left"></i>
                                返回
                            </button>
                        </div>
                    </div>
                </div>
            </form>

        </div>
    </div>




</div>
</body>
</html>